﻿// TableSelectDlg.cpp: 实现文件
//

#include "pch.h"
#include "DAOTest.h"
#include "afxdialogex.h"
#include "TableSelectDlg.h"


// CTableSelectDlg 对话框

IMPLEMENT_DYNAMIC(CTableSelectDlg, CDialogEx)

CTableSelectDlg::CTableSelectDlg(CWnd* pParent)
{

}

CTableSelectDlg::CTableSelectDlg(CDaoDatabase* pDatabase, CWnd* pParent)
	: CDialogEx(IDD_DIALOG_TABLESELECT, pParent)
{
	m_strSelection = _T("");
	m_pDatabase = pDatabase;

}

CTableSelectDlg::~CTableSelectDlg()
{
}

void CTableSelectDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_LBString(pDX, IDC_LIST_SELECT, m_strSelection);
}


BEGIN_MESSAGE_MAP(CTableSelectDlg, CDialogEx)
	ON_LBN_DBLCLK(IDC_LIST_SELECT, &CTableSelectDlg::OnLbnDblclkListSelect)
END_MESSAGE_MAP()


// CTableSelectDlg 消息处理程序


BOOL CTableSelectDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST_SELECT);
	int nTables = m_pDatabase->GetTableDefCount();
	TRACE(_T("CTableSelectDlg::OnInitDialog Tables"), nTables);
	CDaoTableDefInfo tfi;
	for (int i = 0; i < nTables; i++)
	{
		m_pDatabase->GetTableDefInfo(i, tfi);
		TRACE(_T("Table Nmae = %s\n "), tfi.m_strName);
		if (tfi.m_strName.Left(4) != _T("MSys"))
		{
			pListBox->AddString(tfi.m_strName);
		}
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}

void CTableSelectDlg::OnLbnDblclkListSelect()
{
	// TODO: 在此添加控件通知处理程序代码
	OnOK();
}
